package com.hivision.alimqttapi.haddle;


import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.MessagingException;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

/**
 * <p>Title: MqttMessageConsumer</p>
 * <p>Description: TODO</p>
 * <p>Company: www.h-visions.com</p>
 * <p>create date: 2021/03/17</p>
 *
 * @author :jqzhang
 * @version :1.0.0
 */
@Slf4j
@Component
public class MqttMessageConsumer implements MessageHandler {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Override
    public void handleMessage(Message<?> message) throws MessagingException {
        String topic = message.getHeaders().get("mqtt_receivedTopic").toString();
        String msg = message.getPayload().toString();
//        if(msg.contains("01SLRB")||msg.contains("1016RB")&&topic.endsWith("cardata")) {
//            log.info("\n--------------------START-------------------\n" +
//                    "接收到订阅消息:\ntopic:" + topic + "\nmessage:" + msg +
//                    "\n---------------------END--------------------");
//        }
        ObjectMapper mapper = new ObjectMapper();




//        datacollectionRabbitSender.send(msg,properties);
    }
}
